var app = getApp(), fetchApi = require("../../../utils/httpPost.js"), common_Js = require("../../../component/common.js")
import Dialog from '../../../component/vant/dialog/dialog';
import Toast from '../../../component/vant/toast/toast';
Page({
  /**
   * 页面的初始数据
   */
  data: {
    recordList:[],
    hasData:false,
    loading: false,
    netWork: false,
    isLoading: true,
    fire_work_id:0,
    fireWork:{},
    analyses:[],
    measures:[],
    recordType:0,
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    if(options.id){
      this.data.fire_work_id = parseInt(options.id)
    }
  },
  onShow(){
    this.onHttpInit();
  },
  /**
   * 获取页面数据的 http请求
   */
  onHttpInit: function () {
    var that = this
    fetchApi.httpPost('/fire/work/detail', {
      work_id:that.data.fire_work_id,
    }, function (res) {
      console.log("作业票详情返回数据", res)
      if (res.data.code == 0) {
        that.data.fireWork = res.data.data.fireWork;
        that.data.recordType = res.data.data.fireWork.recordType;
        that.setData({
          hasData: true,
          fireWork: res.data.data.fireWork,
          analyses:res.data.data.fireWork.analyses,
        })
      }
      that.setData({
         isLoading: false, loading: true, netWork: true,
      })
    }, function (res) {
        that.setData({ hasData: false,  isLoading: false,  loading: true, netWork: true })
    })
    wx.hideNavigationBarLoading() //完成停止加载
    wx.stopPullDownRefresh() //停止下拉刷新
  },
  goAddAnalysis(e){
    if(this.data.recordType == 0){
      wx.navigateTo({
        url: './addFire/index?workId=' + this.data.fireWork.id,
      })
    } else if(this.data.recordType == 1){// 有限空间
      
      wx.navigateTo({
        url: './addSpace/index?workId=' + this.data.fireWork.id,
      })
    } else if(this.data.recordType == 2){//高空
      wx.navigateTo({
        url: './addFire/index?workId=' + this.data.fireWork.id,
      })
    }
  }
})